import 'package:mi_mang_flutter/api/favorite_words_api.dart';
import 'package:mi_mang_flutter/model/daily_word_model.dart';
import 'package:mi_mang_flutter/model/public/page_model.dart';
import 'package:mi_mang_flutter/network/response_data.dart';
import 'package:mi_mang_flutter/provider/view.dart';

/// 收藏列表Provider
class CollectionPageProvider extends ListViewModel<
    ResponseData<PageModel<DailyWordModel>>, DailyWordModel> {
  /// 文本缩放比例
  double textScaleFactor = 0.8;

  /// 每行列数
  int crossAxisCount = 2;

  /// 当前是否单列显示
  bool isSingle = false;

  @override
  Future<ResponseData<PageModel<DailyWordModel>>> Function() get future => () {
        return FavoriteWordsApi.getPage(pageNum: pageNumber);
      };

  void chageCrossAxisCount() {
    isSingle = !isSingle;
    textScaleFactor = isSingle ? 1.3 : 0.8;
    crossAxisCount = isSingle ? 1 : 2;
    notifyListeners();
  }
}
